#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int get_sum(char *str)
{
    char tmp[512] = {0};
    strcpy(tmp, str);
    char *s = strtok(tmp, ",");
    int sum = 0;
    while (s != NULL)
    {
        int i;
        sscanf(s, "%d", &i);
        sum += i;
        s = strtok(NULL, ",");
    }
    return sum;
}

int main(int argc, char const *argv[])
{
    char a[100] = "12,43,65,13,97,54,19";
    //char a[100] = "10,40,60,130,90,50,190";
    int sum = 0;
    sum = get_sum(a);
    printf("sum=%d\n", sum);
    return 0;
}
